package com.huluobo.a2203parkdemo.news

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/7/29.
 */
@HiltViewModel
class NewsViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel() {
    val getNewsSuccess by lazy { MutableLiveData<String>() }

    fun getNews(body: RequestBody) {
        executeNetRequest(
            { apiService.getNews(body) },
            getNewsSuccess::postValue
        )
    }

    val addNewsSuccevss by lazy { MutableLiveData<String>() }
    fun addNews(body: RequestBody) {
        executeNetRequest(
            { apiService.addNews(body) },
            addNewsSuccevss::postValue
        )
    }
}